package com.zgjkhis.exception;

import com.zgjkhis.api.IResultCode;
import com.zgjkhis.api.ResultCode;
import lombok.Getter;

/**
 * @ Author     ：Tj_Moice
 * @ Date       ：Created in 14:26 2021/3/27/0027
 * @ Description：服务异常处理
 * @ Modified By：
 * @Version: $
 */
public class ServiceException extends RuntimeException{

    private static final long serialVersionUID = 2359767895161832954L;
    @Getter
    private final IResultCode resultCode;

    public ServiceException(String message) {
        super(message);
        this.resultCode = ResultCode.FAILURE;
    }

    public ServiceException(IResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    public ServiceException(IResultCode resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

    public Throwable doFillInStackTrace() {
        return super.fillInStackTrace();
    }

    public IResultCode getResultCode() {
        return this.resultCode;
    }
}
